package hk.ust.android_competition.data_reload_tools;

import android.app.Activity;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;


public class TextReader extends Activity {
    String path;

    public TextReader(String path) {
        this.path = path;
    }

    String line = "";

    public String getData() {
        try {
            File file = new File(path);
            if (!file.exists()) {
                return "Not exist";
            }

            FileInputStream in = new FileInputStream(path);
            if (in != null) {
                InputStreamReader inputReader = new InputStreamReader(in);
                BufferedReader bufferReader = new BufferedReader(inputReader);
                String lineBuf, lineTemp = "";
                try {
                    while ((lineBuf = bufferReader.readLine()) != null)
                        lineTemp += lineBuf;
                    line += lineTemp;
                    inputReader.close();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            in.close();
        } catch (Exception e) {
            String error = "";
            error = e.getMessage();
        }
        return line;
    }


}
